package com.wechat.wechat.handler;

import com.wechat.wechat.exception.SellException;
import com.wechat.wechat.exception.SellerAuthorizeException;
import com.wechat.wechat.utils.ResultVOUtil;
import com.wechat.wechat.vo.ResultVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 统一处理验证登陆失败的错误
 */
@ControllerAdvice
public class SellExceptionHandler {
    @ResponseBody
    @ExceptionHandler(value = SellerAuthorizeException.class)
    public String handleAuthorizeException()
    {
        return "请登陆";
    }

    @ResponseBody
    @ExceptionHandler(value = SellException.class)
    public ResultVO handleSellException(SellException e){
        return ResultVOUtil.error(e.getCode(),e.getMessage());
    }
}
